// 天文事件数据 - 包含近期重要的天文事件
const astronomicalEvents = [
  {
    id: 1,
    title: "象限仪座流星雨极大",
    type: "meteor_shower",
    date: "2024-01-03T21:00:00",
    duration: "2024-01-01T00:00:00/2024-01-05T00:00:00",
    description: "象限仪座流星雨是每年年初的重要天象，预计ZHR可达120颗。今年观测条件极佳，无月光干扰。",
    visibility: "全球可见（北半球更佳）",
    bestTime: "深夜至黎明前",
    magnitude: 2.1,
    tags: ["流星雨", "冬季", "高可见度"]
  },
  {
    id: 2,
    title: "月全食",
    type: "lunar_eclipse",
    date: "2024-03-14T07:00:00",
    duration: "2024-03-14T06:00:00/2024-03-14T10:00:00",
    description: "本次月全食将持续约3小时40分钟，月食期间月亮会呈现美丽的红铜色。",
    visibility: "亚洲、澳大利亚、北美西部可见",
    bestTime: "全食阶段",
    magnitude: null,
    tags: ["月食", "红月亮"]
  },
  {
    id: 3,
    title: "金牛座流星雨极大",
    type: "meteor_shower",
    date: "2024-05-06T23:00:00",
    duration: "2024-05-01T00:00:00/2024-05-10T00:00:00",
    description: "金牛座流星雨以其明亮、缓慢的流星而闻名，ZHR约为10-15颗。",
    visibility: "全球可见",
    bestTime: "晚间至凌晨",
    magnitude: 3.5,
    tags: ["流星雨", "春季"]
  },
  {
    id: 4,
    title: "日环食",
    type: "solar_eclipse",
    date: "2024-06-10T10:00:00",
    duration: "2024-06-10T08:00:00/2024-06-10T12:00:00",
    description: "本次日环食将穿过北极地区，形成壮观的'火环'效应。",
    visibility: "北欧、俄罗斯北部、阿拉斯加",
    bestTime: "环食阶段",
    magnitude: null,
    tags: ["日食", "火环", "高可见度"]
  },
  {
    id: 5,
    title: "英仙座流星雨极大",
    type: "meteor_shower",
    date: "2024-08-13T05:00:00",
    duration: "2024-07-17T00:00:00/2024-08-24T00:00:00",
    description: "英仙座流星雨是年度最受欢迎的流星雨之一，ZHR可达100颗以上。",
    visibility: "北半球最佳",
    bestTime: "深夜至黎明前",
    magnitude: 2.0,
    tags: ["流星雨", "夏季", "高可见度", "推荐观测"]
  },
  {
    id: 6,
    title: "木星冲日",
    type: "planetary_opposition",
    date: "2024-09-11T15:00:00",
    duration: "2024-09-10T00:00:00/2024-09-12T00:00:00",
    description: "木星冲日期间，木星距离地球最近，观测条件最佳，使用小型望远镜即可清晰观测其条纹和卫星。",
    visibility: "全球可见",
    bestTime: "日落后至日出前",
    magnitude: -2.9,
    tags: ["行星", "观测", "望远镜"]
  },
  {
    id: 7,
    title: "猎户座流星雨极大",
    type: "meteor_shower",
    date: "2024-10-21T03:00:00",
    duration: "2024-10-02T00:00:00/2024-11-07T00:00:00",
    description: "猎户座流星雨源自哈雷彗星的尘埃轨迹，流星速度快且常有明亮的火流星。",
    visibility: "全球可见",
    bestTime: "午夜至黎明前",
    magnitude: 3.0,
    tags: ["流星雨", "秋季", "火流星"]
  },
  {
    id: 8,
    title: "月偏食",
    type: "lunar_eclipse",
    date: "2024-10-28T03:00:00",
    duration: "2024-10-28T02:00:00/2024-10-28T06:00:00",
    description: "本次月偏食将使月球的一部分进入地球的本影，形成独特的景观。",
    visibility: "欧洲、非洲、亚洲、澳大利亚",
    bestTime: "偏食阶段",
    magnitude: null,
    tags: ["月食"]
  },
  {
    id: 9,
    title: "狮子座流星雨极大",
    type: "meteor_shower",
    date: "2024-11-17T19:00:00",
    duration: "2024-11-06T00:00:00/2024-11-30T00:00:00",
    description: "狮子座流星雨在某些年份会出现爆发，ZHR可达数千颗。2024年预计不会爆发，但仍值得观测。",
    visibility: "全球可见",
    bestTime: "午夜至黎明前",
    magnitude: 3.5,
    tags: ["流星雨", "秋季"]
  },
  {
    id: 10,
    title: "双子座流星雨极大",
    type: "meteor_shower",
    date: "2024-12-14T16:00:00",
    duration: "2024-12-04T00:00:00/2024-12-17T00:00:00",
    description: "双子座流星雨以其稳定的流量和明亮的流星著称，ZHR可达120颗以上，是年底最值得观测的流星雨。",
    visibility: "北半球最佳",
    bestTime: "深夜至黎明前",
    magnitude: 2.0,
    tags: ["流星雨", "冬季", "高可见度", "推荐观测"]
  },
  {
    id: 11,
    title: "水星东大距",
    type: "planetary_configuration",
    date: "2024-01-12T08:00:00",
    duration: "2024-01-10T00:00:00/2024-01-14T00:00:00",
    description: "水星东大距时，水星位于太阳东侧最远位置，是观测水星的最佳时机。",
    visibility: "日落后西方低空",
    bestTime: "日落后30-60分钟",
    magnitude: -0.6,
    tags: ["行星", "水星", "观测"]
  },
  {
    id: 12,
    title: "土星冲日",
    type: "planetary_opposition",
    date: "2024-05-23T00:00:00",
    duration: "2024-05-22T00:00:00/2024-05-24T00:00:00",
    description: "土星冲日期间，土星亮度最高，使用小型望远镜可清晰观测其美丽的光环。",
    visibility: "全球可见",
    bestTime: "日落后至日出前",
    magnitude: 0.3,
    tags: ["行星", "土星", "望远镜", "光环"]
  }
];

// 导出天文事件数据
export { astronomicalEvents };

// 获取事件的辅助函数
export function getEvents(startDate, endDate) {
  return astronomicalEvents.filter(event => {
    const eventDate = new Date(event.date);
    return (!startDate || eventDate >= new Date(startDate)) && 
           (!endDate || eventDate <= new Date(endDate));
  });
}

// 根据类型获取事件
export function getEventsByType(type) {
  return astronomicalEvents.filter(event => event.type === type);
}

// 获取未来N天的事件
export function getUpcomingEvents(days = 30) {
  const now = new Date();
  const futureDate = new Date();
  futureDate.setDate(now.getDate() + days);
  return getEvents(now, futureDate);
}

// 根据ID获取事件详情
export function getEventById(id) {
  return astronomicalEvents.find(event => event.id === parseInt(id));
}

// 获取事件类型列表
export function getEventTypes() {
  const types = [...new Set(astronomicalEvents.map(event => event.type))];
  const typeNames = {
    'meteor_shower': '流星雨',
    'lunar_eclipse': '月食',
    'solar_eclipse': '日食',
    'planetary_opposition': '行星冲日',
    'planetary_configuration': '行星合日/大距',
    'conjunction': '天体合'  
  };
  return types.map(type => ({ value: type, label: typeNames[type] || type }));
}

// 获取所有事件标签
export function getAllTags() {
  const allTags = astronomicalEvents.flatMap(event => event.tags);
  return [...new Set(allTags)];
}

// 导出完整的事件数据
export default astronomicalEvents;